#!/usr/bin/env python3

import sys

def expand_colour(c):
	return ((c & 0x7fe0) << 1) | (c & 0x1f)

COLOUR_RED = 0x7c00
COLOUR_GREEN = 0x3e0
COLOUR_BLUE = 0x1f

expected = 120 * [expand_colour(COLOUR_RED)] + 200 * [expand_colour(COLOUR_RED | COLOUR_GREEN)] +\
	120 * [expand_colour(COLOUR_GREEN)] + 200 * [expand_colour(COLOUR_GREEN | COLOUR_BLUE)] +\
	120 * [expand_colour(COLOUR_BLUE)] + 200 * [expand_colour(COLOUR_BLUE | COLOUR_RED)]

expected.extend(expected)

actual = list(int(x, 16) for x in open("lcd_dump.hex"))

if len(actual) != len(expected):
	print("Bad length, expected {}, got {}".format(len(expected), len(actual)))
	sys.exit(0)

for i, (a, e) in enumerate(zip(actual, expected)):
	if a != e:
		print("Mismatch at pixel {}, expected {:04x}, got {:04x}".format(i, e, a))
		sys.exit(0)

print("Test PASSED.")
